import {nodeTypeColor} from "../x6Main/X6ConfigFile.js"

function reactLModFn(data) {
    let textStr = ""
    let text = data.text ? data.text : "";
    let typeStr = "";
    let type = data.type;
    let styleStr = ""
    let levelType = data.levelType
    let id = "modBody" + data.id
    let levelTypeDiv = "";//层级div内容
    let reactLModClass = ""
    levelTypeDiv = ``
    if (type == "tab") {
        styleStr = `background-color:${nodeTypeColor.tab};`
        levelTypeDiv  = getLevelTypeDiv(levelType);
        reactLModClass = "flex-d"
    } else if (type == "api") {
        styleStr = `background-color:${nodeTypeColor.api};`
    }else if (type == "sourceTable") {//sourceTable  源端表
        styleStr = `background-color:${nodeTypeColor.sourceTable};`
    }else if (type == "IplatBBService") {//IplatBB服务
        styleStr = `background-color:${nodeTypeColor.IplatBBService};`
    }else if (type == "APIService") {//API服务
        styleStr = `background-color:${nodeTypeColor.APIService};`
    }else {
        styleStr = `background-color:${nodeTypeColor.other};`
    }


    textStr = `<div class="reactLBody">
        <div id="${id}" class = "reactLMod ${reactLModClass}"  data-title='标题栏' style='${styleStr}'>
          ${levelTypeDiv}
          <div  class = "reactLTitleDiv" title = "${text}" >
            <span>${text}</span>
          </div>
        </div>
      </div>`

    return textStr
}

function getLevelTypeDiv(levelType){
  let str = ``
  let colorList = {"ODS":"#E14D58","CDM":"#57AF27","ADS":"#EB9539"}
  let color = colorList[levelType]?colorList[levelType]:"#E3D9CA"
  if(levelType){
    str = `<div class="levelTypeDiv" style="background-color:${color};">
            <span>${levelType}</span>
          </div>`
  }
  
  return str
}

export default reactLModFn